<?php

namespace mamiline2;

/**
 *
 * @package    block_mamiline2
 * @copyright  2013 Takayuki FUWA
 *
 * */

defined('MOODLE_INTERNAL') || die();

function print_header()
{
    global $CFG;

    echo html_writer::start_tag('head');
    echo html_writer::empty_tag('meta', ['charset' => 'UTF-8']);
    echo html_writer::empty_tag('meta', ['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0']);
    echo html_writer::empty_tag('link', ['href' => new moodle_url($CFG->wwwroot . '/blocks/mamiline/css/bootstrap.min.css'), 'rel' => 'stylesheet']);
    echo html_writer::empty_tag('link', ['href' => new moodle_url($CFG->wwwroot . '/blocks/mamiline/css/sb-admin.css'), 'rel' => 'stylesheet']);
    echo html_writer::empty_tag('link', ['href' => new moodle_url($CFG->wwwroot . '/blocks/mamiline/css/profile.css'), 'rel' => 'stylesheet']);
    echo html_writer::empty_tag('link', ['href' => new moodle_url($CFG->wwwroot . '/blocks/mamiline/css/simplePagination.css'), 'rel' => 'stylesheet']);
    echo html_writer::end_tag('head');
}

function print_top_navbar()
{
    global $CFG;

    echo html_writer::start_tag('nav', ['class' => 'navbar navbar-default', 'role' => 'navigation']);
    echo html_writer::start_tag('div', ['class' => 'navbar-header']);
    echo html_writer::link(new moodle_url($CFG->wwwroot . '/blocks/mamiline2/index.php'),
        get_string('pluginname', 'block_mamiline2'), ['class' => 'navbar-brand']);
    echo html_writer::end_tag('div');
    echo html_writer::start_tag('div',
        ['class' => 'collapse navbar-collapse', 'id' => 'bs-example-navbar-collapse-1']);
    echo html_writer::start_tag('ul', ['class' => 'nav navbar-nav navbar-right']);
    echo html_writer::tag('li',
        html_writer::link(new moodle_url($CFG->wwwroot . '/blocks/mamiline2/index.php'), get_string('top', 'block_mamiline2')));
    echo html_writer::tag('li',
        html_writer::link(new moodle_url($CFG->wwwroot . '/blocks/mamiline2/index.php'), get_string('close', 'block_mamiline2')));
    echo html_writer::end_tag('ul');
    echo html_writer::end_tag('div');
    echo html_writer::end_tag('nav');
}

function print_left_navbar($position = 0)
{
    global $OUTPUT, $USER, $CFG;

    echo html_writer::start_tag('nav', ['id' => 'sidebar', 'class' => 'navbar-default navbar-static-side']);
    echo html_writer::start_tag('section', ['class' => 'row']);
    echo html_writer::start_tag('article', ['class' => 'col-sm-12 col-md-12 col-lg-12']);
    echo html_writer::start_tag('div', ['class' => 'profile']);
    echo html_writer::tag('div', $OUTPUT->user_picture($USER, ['size'=>140, 'class' => 'img-circle']), ['id' => 'userinfo']);
    echo html_writer::tag('p', fullname($USER));
    echo html_writer::end_tag('div');
    echo html_writer::start_tag('ul', ['class' => 'list-group', 'id' => 'side-menu']);
    echo html_writer::tag('li',
        html_writer::link($CFG->wwwroot . '/blocks/mamiline2/index.php', get_string('top', 'block_mamiline2')),
        ['class' => 'list-group-item active']
    );
    echo html_writer::tag('li',
        html_writer::link($CFG->wwwroot . '/blocks/mamiline2/view/student/timeline/', get_string('timeline', 'block_mamiline2')),
        ['class' => 'list-group-item']
    );
    echo html_writer::tag('li',
        html_writer::link($CFG->wwwroot . '/blocks/mamiline2/view/student/quiz/', get_string('quiz', 'block_mamiline2')),
        ['class' => 'list-group-item']
    );
    echo html_writer::tag('li',
        html_writer::link($CFG->wwwroot . '/blocks/mamiline2/view/student/assign/', get_string('assign', 'block_mamiline2')),
        ['class' => 'list-group-item']
    );
    echo html_writer::tag('li',
        html_writer::link($CFG->wwwroot . '/blocks/mamiline2/view/student/forum/', get_string('forum', 'block_mamiline2')),
        ['class' => 'list-group-item']
    );
    echo html_writer::end_tag('ul');
    echo html_writer::end_tag('article');
    echo html_writer::end_tag('section');
    echo html_writer::end_tag('nav');
}